﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Web.Admin.Page_Template.Edit" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>

<!DOCTYPE html>

<%="<!--[if IE 8]> <html class=\"ie8 no-js\"> <![endif]-->"%>
<%="<!--[if IE 9]> <html class=\"ie9 no-js\"> <![endif]-->"%>
<%="<!--[if !IE]><!-->"%>
<html>
<%="<!--<![endif]-->"%>
    <!-- BEGIN HEAD -->

    <head>
        <meta charset="utf-8" />
        <title><%=Evan.Common.CommFun.GetAppSetting("AdminTitle") %> - 后台管理系统</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta content="width=device-width, initial-scale=1" name="viewport" />
        <!-- #include file="../include/com_res_css.inc" -->
    </head>
    <!-- END HEAD -->
    
    <body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white">
        <!-- BEGIN HEADER -->
        
        <!-- #include file="../include/top_bar.inc" -->

        <!-- END HEADER -->
        <!-- BEGIN HEADER & CONTENT DIVIDER -->
        <div class="clearfix"> </div>
        <!-- END HEADER & CONTENT DIVIDER -->
        <!-- BEGIN CONTAINER -->
        <div class="page-container">
            <!-- BEGIN SIDEBAR -->
            
            <!-- #include file="../include/left_menu.inc" -->
            
            <!-- END SIDEBAR -->
            <!-- BEGIN CONTENT -->
            <div class="page-content-wrapper">
                <!-- BEGIN CONTENT BODY -->
                <div class="page-content">
                    <!-- BEGIN PAGE HEADER-->
                    <!-- BEGIN THEME PANEL -->
                    <!-- #include file="../include/theme_panel.inc" -->
                    <h3 class="page-title"> <%=TempPageTitle %>管理 </h3>
                    <!-- END PAGE TITLE-->
                    <!-- END PAGE HEADER-->
                    <!-- BEGIN PAGE CONTENT-->

                                    <div class="portlet light bordered">
                                        <div class="portlet-title tabbable-line">

                                            <ul class="nav nav-tabs ">
                                                <li class="active">
                                                    <a href="#tab_1" data-toggle="tab" aria-expanded="true"> <%=TempPageTitle %>信息 </a>
                                                </li>
                                            </ul>
                                        
                                            <div class="caption">
                                                <i class="glyphicon glyphicon-list-alt font-red"></i>
                                                <span class="caption-subject font-red bold uppercase"><%=TempPageTitle %>管理</span>
                                            </div>

                                        </div>
                                        <div class="tab-content">

                                            <div class="tab-pane active" id="tab_1">
                                                <div class="form">
                                                    <div class="form-horizontal form-row-seperated">
                                                        <div class="form-body">


                                                            <% 
                                                                Evan.Model.SysModel.HtmlHelperModel Title = new Evan.Model.SysModel.HtmlHelperModel();
                                                                if (TemplateCategory.ToLower() == "Template".ToLower())
                                                                {
                                                                    Title = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "名称", PlaceHoder = TempPageTitle + "名称", Notice = "模板生成后命名为 [模板名称 - 模板说明]<br/>模板名称命名规则(只需填名称部分) :以模板用途进行说明<br/>如:[<a class='setDefaultValue'>产品列表</a>-热门产品] [<a class='setDefaultValue'>新闻列表</a>-左图右文]", FieldName = "Title", FieldVerify = "notnull", MaxLength = 25, FieldType = "input" };
                                                                }
                                                                if (TemplateCategory.ToLower() == "Component".ToLower())
                                                                {
                                                                    Title = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "名称", PlaceHoder = TempPageTitle + "名称", Notice = "组件名称命名规则 , 以组件用途进行命名<br/>如 : <a class='setDefaultValue'>栏目Banner</a> , <a class='setDefaultValue'>二级导航</a>", FieldName = "Title", FieldVerify = "notnull", MaxLength = 25, FieldType = "input" };
                                                                }

                                                                //模板生成后命名为 [模板名称 - 模板说明]<br/>模板名称命名规则(只需填名称部分) :以模板用途进行说明<br/>如:[<a class='setDefaultValue'>产品列表</a>-热门产品] [<a class='setDefaultValue'>新闻列表</a>-左图右文]
                                                                Evan.Model.SysModel.HtmlHelperModel Intro = new Evan.Model.SysModel.HtmlHelperModel();
                                                                if (TemplateCategory.ToLower() == "Template".ToLower())
                                                                {
                                                                    Intro = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "说明", PlaceHoder = TempPageTitle + "说明", Notice = "模板生成后命名为 [模板名称 - 模板说明]<br/>模板名称命名规则(只需填说明部分) :以模板用途/结构进行说明<br/>如:[产品列表-<a class='setDefaultValue'>热门产品</a>] [新闻列表-<a class='setDefaultValue'>左图右文</a>]", FieldName = "Intro", FieldVerify = "notnull", MaxLength = 255, FieldType = "textarea" };
                                                                }
                                                                //模块编辑没有说明字段

                                                                Evan.Model.SysModel.HtmlHelperModel TemplatePath = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "文件夹", PlaceHoder = TempPageTitle + "文件夹", Notice = "不允许使用 [include,common] , 只允许输入英文 , 禁止出现空格 , 可以为空", FieldName = "TemplatePath", FieldVerify = "", MaxLength = 50, FieldType = "input", Hide = Evan.Common.SysComm.IsModuleSystem() };

                                                                Evan.Model.SysModel.HtmlHelperModel TemplateName = new Evan.Model.SysModel.HtmlHelperModel();
                                                                if (GlobalConfigModel.IsModuleSystem)
                                                                {
                                                                    if (TemplateCategory.ToLower() == "Template".ToLower())
                                                                    {
                                                                        TemplateName = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "文件名", PlaceHoder = TempPageTitle + "文件名", Notice = "只允许输入英文 , 禁止出现空格 , 用于命名该" + TempPageTitle + "的文件名称 , 与设计无关 , 不影响设计版面<br/><b class='font-red'>禁止使用 aaa , 123 , abc 等无意义字符作为名称 , 名称必须有意义, 比如 newslist, newslisthasimg, newslistwithtxt</b>", FieldName = "TemplateName", FieldVerify = "numOrLetter", MaxLength = 50, FieldType = "input" };
                                                                    }
                                                                    if (TemplateCategory.ToLower() == "Component".ToLower())
                                                                    {
                                                                        TemplateName = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "文件名", PlaceHoder = TempPageTitle + "文件名", Notice = "只允许输入英文 , 禁止出现空格 , 输入组件名称的英文翻译,如 <a class='setDefaultValue'>pagebanner</a> , <a class='setDefaultValue'>subnav</a> . 该命名不影响设计版面<br/><b class='font-red'>禁止使用 aaa , 123 , abc 等无意义字符作为名称 , 名称必须有意义, 比如 newslist, newslisthasimg, newslistwithtxt</b>", FieldName = "TemplateName", FieldVerify = "numOrLetter", MaxLength = 50, FieldType = "input" };
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    TemplateName = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "文件名", PlaceHoder = TempPageTitle + "文件名", Notice = "只允许输入英文 , 禁止出现空格 , 用于命名该" + TempPageTitle + "的文件名称", FieldName = "TemplateName", FieldVerify = "notnull", MaxLength = 50, FieldType = "input" };
                                                                }
                                                                //Evan.Model.SysModel.HtmlHelperModel TemplateName = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "文件名", PlaceHoder = TempPageTitle + "文件名", Notice = "只允许输入英文 , 禁止出现空格 , 用于命名该" + TempPageTitle+"的文件名称 , 与设计无关 , 不影响设计版面", FieldName = "TemplateName", FieldVerify = "notnull", MaxLength = 50, FieldType = "input" };


                                                                Evan.Model.SysModel.HtmlHelperModel TemplateType = new Evan.Model.SysModel.HtmlHelperModel();

                                                                if (TemplateCategory.ToLower() == "Template".ToLower())
                                                                {
                                                                    Dictionary<string, string> TemplateTypeDic = new Dictionary<string, string>();
                                                                    TemplateTypeDic.Add("Default", "综合页");
                                                                    TemplateTypeDic.Add("List", "列表页");
                                                                    TemplateTypeDic.Add("Detail", "详细页");
                                                                    TemplateTypeDic.Add("SinglePage", "单页面");
                                                                    TemplateTypeDic.Add("Index", "首页");
                                                                    if (GlobalConfigModel.IsModuleSystem)
                                                                    {
                                                                        TemplateType = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "类型", PlaceHoder = TempPageTitle + "类型", Notice = "根据" + TempPageTitle + "内容选择对应的模板类型", FieldName = "TemplateType", FieldVerify = "notnull", MaxLength = 50, FieldType = "select", SelectItem = TemplateTypeDic };
                                                                    }
                                                                    else
                                                                    {
                                                                        TemplateType = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "类型", PlaceHoder = TempPageTitle + "类型", Notice = "根据" + TempPageTitle + "内容选择对应的模板类型", FieldName = "TemplateType", FieldVerify = "notnull", MaxLength = 50, FieldType = "select", SelectItem = TemplateTypeDic };
                                                                    }
                                                                }

                                                                if (TemplateCategory.ToLower() == "Component".ToLower())
                                                                {
                                                                    Dictionary<string, string> ComponentTypeDic = new Dictionary<string, string>();
                                                                    ComponentTypeDic.Add("Head", "头部");
                                                                    ComponentTypeDic.Add("Foot", "底部");
                                                                    ComponentTypeDic.Add("Other", "其它");
                                                                    TemplateType = new Evan.Model.SysModel.HtmlHelperModel { Title = TempPageTitle + "类型", PlaceHoder = TempPageTitle + "类型", Notice = "必须选择对应的类型 , 除去头部底部外 , 其余都选择 [其它]", FieldName = "TemplateType", FieldVerify = "notnull", MaxLength = 50, FieldType = "select", SelectItem = ComponentTypeDic };
                                                                }


                                                                //页面类型
                                                                List<Evan.Model.SysModel.HtmlHelperModel> mm = new List<Evan.Model.SysModel.HtmlHelperModel>();

                                                                if (TemplateCategory.ToLower() == "Template".ToLower())
                                                                {
                                                                    //Dictionary<string,string> PageTypeDic = Evan.Template.TemplateHelper.PageTypeDic();
                                                                    //PageTypeDic.Remove("0");
                                                                    Evan.Model.SysModel.HtmlHelperModel TPT = new Evan.Model.SysModel.HtmlHelperModel();
                                                                    if (GlobalConfigModel.IsModuleSystem)
                                                                    {
                                                                        TPT = new Evan.Model.SysModel.HtmlHelperModel { Title = "栏目类型", PlaceHoder = "栏目类型选择", Notice = "根据模板内容选择对应的栏目类型", FieldName = "TemplatePageType", FieldVerify = "notnull", MaxLength = 25, FieldType = "select", SelectItem = Evan.Template.TemplateHelper.PageTypeDicForModule() };
                                                                    }
                                                                    else
                                                                    {
                                                                        TPT = new Evan.Model.SysModel.HtmlHelperModel { Title = "栏目类型", PlaceHoder = "栏目类型选择", Notice = "栏目类型对应不同的管理页面", FieldName = "TemplatePageType", FieldVerify = "notnull", MaxLength = 25, FieldType = "select", SelectItem = Evan.Template.TemplateHelper.PageTypeDic() };
                                                                    }
                                                                    mm.Add(TPT);
                                                                }

                                                                mm.Add(TemplateType);
                                                                mm.Add(Title);
                                                                if (TemplateCategory.ToLower() == "Template".ToLower())
                                                                {
                                                                    mm.Add(Intro);
                                                                }

                                                                mm.Add(TemplatePath);
                                                                mm.Add(TemplateName);

                                                                foreach (Evan.Model.SysModel.HtmlHelperModel item in mm)
                                                                {
                                                                    Response.Write(Evan.Common.HtmlHelper.HtmlBuild(item));
                                                                }


                                                                Evan.Model.SysModel.HtmlHelperModel TemplateCategoryInput = new Evan.Model.SysModel.HtmlHelperModel { Title = "类型", PlaceHoder = "类型", Notice = "当前为何种类型 模板/组件", FieldName = "TemplateCategory", FieldVerify = "notnull", MaxLength = 25, FieldType = "input", DefaultValue = TemplateCategory, Hide=true };
                                                                Response.Write(Evan.Common.HtmlHelper.HtmlBuild(TemplateCategoryInput));

                                                            %>


                                                            
                                                                
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            
                                        </div>


                                        <div class="form-actions form-submit-row">
                                            <div class="form-group">
                                                <label class="control-label col-md-2"></label>
                                                <div class="col-md-6">
                                                    <button type="button" class="btn green submit_template"><i class="fa fa-check"></i>&nbsp;&nbsp;提交</button>
                                                    <button type="button" class="btn default" onclick="JumpList();"><i class="fa fa-mail-reply"></i>&nbsp;&nbsp;返回</button>
                                                </div>
                                            </div>
                                            <div class="clear">
                                            </div>
                                        </div>

                                    </div>

                    
                    <!-- END PAGE CONTENT-->
                </div>
                <!-- END CONTENT BODY -->
            </div>
            <!-- END CONTENT -->
            
        </div>
        <!-- END CONTAINER -->
        <!-- #include file="../include/footer.inc" -->
   <!-- #include file="../include/com_res_js.inc" -->
    </body>
     <script  type="text/javascript">
         var model = <%=(Evan.Model.ConvertModel.ConvertToJson(Model))%>;
         SetModel(model);
         <% if (GlobalConfigModel.IsModuleSystem && Id>0) { %>
         $("select[field='TemplatePageType']").prop("disabled", true);
         $("select[field='TemplateType']").prop("disabled", true);
         $("input[field='TemplateName']").prop("disabled", true);
         <% } %>
         
         $(function(){
             $("div.tab-content [verify]").Verify({
                 subtn: $(".submit_template"),
                 callback: function (res, type, obj) { //res=验证结果 type=验证类型 obj=验证的对象  //当验证失败才会调用此方法
                     //console.log(res, type, obj);
                     VerifyHandle(obj.closest(".form-group"), res);
                 },
                 submit: function (res) {
                     //console.log(1);
                 }
             });
            
             //提交按钮的功能 后台统一提交地址 统管编辑和添加
             $(".submit_template").on("click", function () {
                 //检查一遍输入状态
                 if (!CheckVerify()) {
                     notice("请检查您的输入项是否有错误", "error");
                     return false;
                 }
                 //检查必要参数
                 if (GetQs("action") == "" || GetQs("t") == "") {
                     alert("您的访问异常 , 请重新登录后再尝试操作", function () {
                         window.location.href = appConfig.adminPath + "login.aspx?action=loginout";
                     });
                     return false;
                 }
                 var ActionType = "操作";
                 if (IsAddAction()) {
                     ActionType = "添加";
                 }
                 if (IsEditAction()) {
                     ActionType = "编辑";
                 }

                 var _this = this;
                 model = MakeModel();
                 var data = { model: JSON.stringify(model), table: "Template", classid: "" };
                 $(_this).button('loading');
                 AjaxSubmit(appConfig.adminPath + "ashx/administrator.ashx", GetQs("action"), data, function (f, d) {
                     $(_this).button('reset');
                     if (f) {
                         //请求成功
                         if (parseInt(d.result) > 0) {
                             alert(ActionType + "成功", function () {
                                 if (IsEditAction() || IsAddAction()) { $.Cookie_Del(AutoSave_CookieName()) }
                                 setTimeout(function () {
                                     if (GetQs("t") == "Versions") {
                                         window.location.href = window.location.href;
                                     } else {
                                         JumpList();
                                     }
                                 }, 500);
                             });
                         }
                         else if (parseInt(d.result) == -99) {
                             alert("登录超时 , 请重新登录", function () {
                                 setTimeout(function () {
                                     JumpLogin();
                                 }, 500);
                             });
                         }
                         else if (parseInt(d.result) == -100) {
                             alert("权限不足 , 无法操作 !");
                         }
                         else {
                             alert(ActionType + "失败 , 请稍后重试 !");
                         }
                     }
                     else {
                         //请求失败
                         alert("请求出错 , 请稍后刷新重试 !");
                     }
                 });
             });


         })
  </script>
</html>

